package 递归实现指数型枚举2;

import java.util.Arrays;
import java.util.Scanner;


public class Main {
    static int N = 20, n;
    static int[] a = new int[N];
    static boolean[] st = new boolean[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a, 0, n);
        dfs(0);
    }

    private static void dfs(int u) {
        if (u == n) {
            for (int i = 0; i < n; i++) {
                if (st[i]) {
                    System.out.print(a[i] + " ");
                }
            }
            System.out.println();
            return;
        }
        int k = u;
        while (k < n && a[k] == a[u]) {
            k++;
        }
        dfs(k);
        for (int i = u; i < k; i++) {
            st[i] = true;
            dfs(k);
        }
        for (int i = u; i < k; i++) {
            st[i] = false;
        }
    }
}
